<?php
$WIKIRIN_USER_AGENT = $_SERVER['HTTP_USER_AGENT'];
// PukiWiki - Yet another WikiWikiWeb clone.
// $Id: index.php,v 1.9 2006/05/13 07:39:49 henoheno Exp $
// Copyright (C) 2001-2006 PukiWiki Developers Team
// License: GPL v2 or (at your option) any later version

// Error reporting
//error_reporting(0); // Nothing
//error_reporting(E_ERROR | E_PARSE); // Avoid E_WARNING, E_NOTICE, etc
//error_reporting(E_ALL); // Debug purpose
error_reporting(E_ALL & ~E_DEPRECATED &~E_STRICT);

require_once dirname(__FILE__) . '/lib/tiny_link.php';
$objTiny = new lib_tinylink();
$redirect = $objTiny->getReal();
if ($redirect !== FALSE) {
	header('Location: ' . $redirect);
	exit;
}

if (isset($_REQUEST['cmd'])) {
	if ($_REQUEST['cmd'] == 'edit') {
		if (! isset($_SESSION)) {
			session_start();
		}
		if (! isset($_SESSION['EDIT'])) {
			header('Location: http://www.yahoo.co.jp/');
			exit;
		}
		if ($_SESSION['EDIT']  != '1') {
			header('Location: http://www.yahoo.co.jp/');
			exit;
		}
	}
}

// Special
//define('PKWK_READONLY',  1);
//define('PKWK_SAFE_MODE', 1);
//define('PKWK_OPTIMISE',  1);
//define('TDIARY_THEME',   'digital_gadgets');

// Directory definition
// (Ended with a slash like '../path/to/pkwk/', or '')
define('DATA_HOME',	'');
define('LIB_DIR',	'lib/');

require(LIB_DIR . 'pukiwiki.php');

class user
{
	const USER = 'USER';
	const STAB_USER_NAME = 'hariushi';

	public static function set($user){
		if (!isset($_SESSION)){
			session_start();
		}
		if (isset($_SESSION[self::USER])){
			unset($_SESSION[self::USER]);
		}
		if ($user != self::STAB_USER_NAME){
			return FALSE;
		}
		$_SESSION[self::USER] = $user;
		return TRUE;
	}

	public static function auth(){
		if (!isset($_SESSION)){
			session_start();
		}
		if (!isset($_SESSION[self::USER])){
			return FALSE;
		}
		if ($_SESSION[self::USER] != self::STAB_USER_NAME) {
			return FALSE;
		}
		return TRUE;
	}
}
?>
